Leaflet Map Bounds—以像素坐标表示矩形区域

Leaflet Map Bounds—以像素坐标表示矩形区域

Usage example

var p1 = L.point(10, 10),
p2 = L.point(40, 60),
bounds = L.bounds(p1, p2);

All Leaflet methods that accept Bounds objects also accept them in a simple Array form (unless noted otherwise), so the bounds example above can be passed like this:

所有接受Bounds对象的Leaflet方法也以简单的Array形式接受它们(除非另有说明),因此上面的边界示例可以这样传递:

otherBounds.intersects([[10, 10], [40, 60]]);

Note that Bounds does not inherit from Leaflet’s Class object, which means new classes can’t inherit from it, and new methods can’t be added to it with the include function.

注意,Bounds不会从Leaflet的Class对象继承,这意味着新的类不能从它继承,并且不能使用include函数向它添加新的方法。

Creation

FactoryDescription
L.bounds(<Pointcorner1, <Pointcorner2)Creates a Bounds object from two corners coordinate pairs.
从两个角坐标对创建边界对象。
L.bounds(<Point[]> points)Creates a Bounds object from the given array of points.
从给定的点阵列创建边界对象。

Methods

MethodReturnsDescription
extend(<Pointpoint)thisExtends the bounds to contain the given point.
扩展边界以包含给定点。
extend(<BoundsotherBounds)thisExtend the bounds to contain the given bounds
扩展边界以包含给定的边界
getCenter(<Boolean> round?)PointReturns the center point of the bounds.
返回边界的中心点。
getBottomLeft()PointReturns the bottom-left point of the bounds.
返回边界的左下角点。
getTopRight()PointReturns the top-right point of the bounds.
返回边界的右上角。
getTopLeft()PointReturns the top-left point of the bounds (i.e. this.min).
返回边界的左上点(即this.min)。
getBottomRight()PointReturns the bottom-right point of the bounds (i.e. this.max).
返回边界的右下点(即this.max)。
getSize()PointReturns the size of the given bounds
返回给定边界的大小
contains(<BoundsotherBounds)BooleanReturns true if the rectangle contains the given one.
如果矩形包含给定的矩形,则返回true。
contains(<Pointpoint)BooleanReturns true if the rectangle contains the given point.
如果矩形包含给定点,则返回true。
intersects(<BoundsotherBounds)BooleanReturns true if the rectangle intersects the given bounds. Two bounds intersect if they have at least one point in common.
如果矩形与给定边界相交,则返回true。如果两个边界至少有一个公共点,则它们相交。
overlaps(<BoundsotherBounds)BooleanReturns true if the rectangle overlaps the given bounds. Two bounds overlap if their intersection is an area.
如果矩形与给定边界重叠,则返回true。如果两个边界的交点是一个区域,则两个边界重叠。
isValid()BooleanReturns true if the bounds are properly initialized.
如果边界正确初始化,则返回true。
pad(<Number> bufferRatio)BoundsReturns bounds created by extending or retracting the current bounds by a given ratio in each direction. For example, a ratio of 0.5 extends the bounds by 50% in each direction. Negative values will retract the bounds.
返回通过在每个方向上按给定比率扩展或收缩当前边界而创建的边界。例如,0.5的比率将边界在每个方向上扩展50%。负值将收回边界。
equals(<BoundsotherBounds)BooleanReturns true if the rectangle is equivalent to the given bounds.
如果矩形等于给定边界,则返回true。

Properties

PropertyTypeDescription
minPointThe top left corner of the rectangle.
矩形的左上角。
maxPointThe bottom right corner of the rectangle.
矩形的右下角。
0 0 投票数
文章评分
订阅评论
提醒
0 评论
最旧
最新 最多投票
内联反馈
查看所有评论
0
希望看到您的想法,请您发表评论x